﻿namespace Socket.Core
{
    using System;
    using System.Runtime.CompilerServices;

    public class KeepLiveArgs
    {
        public KeepLiveArgs(int milliSeconds)
        {
            this.Enable = true;
            this.MilliSeconds = milliSeconds;
        }

        public KeepLiveArgs(int milliSeconds, bool enable)
        {
            this.Enable = enable;
            this.MilliSeconds = milliSeconds;
        }

        public byte[] GetOptionValues()
        {
            byte[] array = new byte[12];
            BitConverter.GetBytes(!this.Enable ? 0 : 1).CopyTo(array, 0);
            BitConverter.GetBytes((uint) 0x1388).CopyTo(array, 4);
            BitConverter.GetBytes((uint) this.MilliSeconds).CopyTo(array, 8);
            return array;
        }

        public bool Enable { get; private set; }

        public int MilliSeconds { get; private set; }
    }
}

